<?php
  $split=explode(".",$image);
  $orgname=$split[0];
  $extension=$split[1];

  //$name=$image;
  $path="../images/category/".$catImageIns.".".$extension;
  $pathDb="images/category/".$catImageIns.".".$extension;
  move_uploaded_file($_FILES["image"]["tmp_name"],$path);
  list($width, $height) = getimagesize($path);
   $towidth=176;
   $toheight=ceil(($height/$width)*220);
   if($toheight>220)
   {
   		$toheight=220;
   		$towidth=ceil(($width/$height)*220);
   }

 $imageResized = imagecreatetruecolor($towidth, $toheight);
 if (preg_match("/jpg|jpeg|pjpeg/",strtolower($extension)))
	{
		$src_img=imagecreatefromjpeg($path);
		imagecopyresampled($imageResized,$src_img, 0, 0, 0, 0, $towidth, $toheight, $width, $height);
		ImageJpeg($imageResized,$path,100);
	}
if (preg_match("/png/",strtolower($extension)))
	{
		$src_img=imagecreatefrompng($path);
		imagecopyresampled($imageResized,$src_img, 0, 0, 0, 0, $towidth, $toheight, $width, $height);
		ImageJpeg($imageResized,$path,100);
	}

if (preg_match("/gif/",strtolower($extension)))
	{
		$src_img=imagecreatefromgif($path);
		imagecopyresampled($imageResized,$src_img, 0, 0, 0, 0, $towidth, $toheight, $width, $height);
		ImageJpeg($imageResized,$path,100);
	}

if (preg_match("/bmp/",strtolower($extension)))
	{
		$src_img=imagecreatefrompng($path);
	}
   // imagecopyresampled($imageResized,$src_img, 0, 0, 0, 0, $towidth, $toheight, $width, $height);
?>